//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "mainTest.h"
#include "..\xftpfunctions.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;

#define BUFSIZE (10*1024)
char *buf;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{
    buf= new char[BUFSIZE];
}
//---------------------------------------------------------------------------


void __fastcall TForm1::Button1Click(TObject *Sender)
{
    xftpConnect(Edit1->Text.c_str(), Edit2->Text.ToIntDef(0),
                                 Edit3->Text.c_str(), Edit4->Text.c_str());

    xftpLastError(buf);
    statusLbl->Caption= buf;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
    xftpDisconnect();
    xftpLastError(buf);
    statusLbl->Caption= buf;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
    xftpListDir(buf, BUFSIZE);
    Memo1->Lines->Text= buf;
    xftpLastError(buf);
    statusLbl->Caption= buf;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button7Click(TObject *Sender)
{
    xftpChangeDir(Edit5->Text.c_str());

    xftpLastError(buf);
    statusLbl->Caption= buf;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
    delete buf;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button9Click(TObject *Sender)
{
    xftpCurDir(buf);
    Edit5->Text= buf;

    xftpLastError(buf);
    statusLbl->Caption= buf;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button6Click(TObject *Sender)
{
    xftpCreateDir(Edit6->Text.c_str());

    xftpLastError(buf);
    statusLbl->Caption= buf;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button8Click(TObject *Sender)
{
    xftpDeleteDir(Edit6->Text.c_str());

    xftpLastError(buf);
    statusLbl->Caption= buf;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button4Click(TObject *Sender)
{
    xftpDelete(Edit6->Text.c_str());

    xftpLastError(buf);
    statusLbl->Caption= buf;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button5Click(TObject *Sender)
{
    xftpRename(Edit6->Text.c_str(), Edit7->Text.c_str());

    xftpLastError(buf);
    statusLbl->Caption= buf;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button10Click(TObject *Sender)
{
    xftpPut(Edit6->Text.c_str(), Edit7->Text.c_str());

    xftpLastError(buf);
    statusLbl->Caption= buf;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button11Click(TObject *Sender)
{
    xftpGet(Edit7->Text.c_str(), Edit6->Text.c_str());

    xftpLastError(buf);
    statusLbl->Caption= buf;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button12Click(TObject *Sender)
{
    xftpMode(fmASCII);

    xftpLastError(buf);
    statusLbl->Caption= buf;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button13Click(TObject *Sender)
{
    xftpMode(fmBinary);

    xftpLastError(buf);
    statusLbl->Caption= buf;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button14Click(TObject *Sender)
{
    xftpAbort();

    xftpLastError(buf);
    statusLbl->Caption= buf;
}
//---------------------------------------------------------------------------

